home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------*\
- | MessageBox.cpp - CtlHTML(tm) Control Library Test Program |
- | Windmill Point Software, Alburg, VT 05440 |
- | Copyright (c) 1999, Windmill Point Software |
- | All Rights Reserved. |
- \*---------------------------------------------------------------------------*/
-
- #include "stdafx.h"
- #include "CtlHTML Demo.h"
- #include "DevUI.h"
- #include "..\CtlHtml.h"
- #include "MessageBox.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- #define ID_TEST 100
-
- // globals
-
- int DefaultButtonID = 100;
-
- // helper function
-
- void ReloadComboList (CComboBox *pCombo, CMcMRUList *pComboMru, LPCTSTR editText);
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CMessageBoxOptions property page
-
- IMPLEMENT_DYNCREATE(CMessageBoxOptions, CPropertyPage)
-
- BEGIN_MESSAGE_MAP(CMessageBoxOptions, CPropertyPage)
- //{{AFX_MSG_MAP(CMessageBoxOptions)
- ON_CBN_SELCHANGE(IDC_STANDARD_BUTTONS, OnChangeStandardButtons)
- ON_BN_CLICKED(IDC_CUSTOM_BUTTONS, OnCustomButtons)
- ON_WM_ACTIVATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- CMessageBoxOptions::CMessageBoxOptions() : CPropertyPage(CMessageBoxOptions::IDD)
- {
- //{{AFX_DATA_INIT(CMessageBoxOptions)
- m_DefaultButton = -1;
- m_DisplayInFutureText = _T("");
- m_HelpID = 0;
- m_MessageText = _T("");
- m_ResourceIcon = -1;
- m_ReturnValue = _T("");
- m_StandardButtons = -1;
- m_StandardIcon = -1;
- m_Timeout = -1;
- m_TitleText = _T("");
- //}}AFX_DATA_INIT
-
- m_ButtonList[0].ID = -1;
- m_pButtonList = 0;
- m_Flags = 0;
- m_IconNumber = 0;
- m_pTitleMRU = m_pMessageMRU = m_pFutureMRU = 0;
- }
-
- CMessageBoxOptions::~CMessageBoxOptions()
- {
- }
-
- void CMessageBoxOptions::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
-
- //{{AFX_DATA_MAP(CMessageBoxOptions)
- DDX_CBIndex(pDX, IDC_DEFAULT_BUTTONS, m_DefaultButton);
- DDX_CBString(pDX, IDC_DISPLAY_IN_FUTURE, m_DisplayInFutureText);
- DDX_Text(pDX, IDC_HELPID, m_HelpID);
- DDX_CBString(pDX, IDC_MESSAGE_BOX, m_MessageText);
- DDX_CBIndex(pDX, IDC_RESOURCE_ICON, m_ResourceIcon);
- DDX_Text(pDX, IDC_RETURN_VALUE, m_ReturnValue);
- DDX_CBIndex(pDX, IDC_STANDARD_BUTTONS, m_StandardButtons);
- DDX_CBIndex(pDX, IDC_STANDARD_ICON, m_StandardIcon);
- DDX_Text(pDX, IDC_TIMEOUT_TIME, m_Timeout);
- DDV_MinMaxInt(pDX, m_Timeout, 0, 600);
- DDX_CBString(pDX, IDC_TITLE_BOX, m_TitleText);
- //}}AFX_DATA_MAP
-
- if (pDX->m_bSaveAndValidate)
- {
- // add current strings to MRU
- m_pTitleMRU->AddString(m_TitleText);
- m_pMessageMRU->AddString(m_MessageText);
- m_pFutureMRU->AddString(m_DisplayInFutureText);
-
- // set m_pButtonList
- if (m_StandardButtons == 0)
- m_pButtonList = m_ButtonList;
- else
- m_pButtonList = 0;
-
- // set m_Flags
- m_Flags = 0;
- switch (m_StandardButtons)
- {
- case 1: m_Flags |= MB_ABORTRETRYIGNORE; break;
- case 2: m_Flags |= HTMLMB_CANCEL; break;
- case 3: m_Flags |= HTMLMB_CONTINUE; break;
- case 4: m_Flags |= MB_OK; break;
- case 5: m_Flags |= MB_OKCANCEL; break;
- case 6: m_Flags |= MB_RETRYCANCEL; break;
- case 7: m_Flags |= MB_YESNO; break;
- case 8: m_Flags |= MB_YESNOCANCEL; break;
- }
- switch (m_DefaultButton)
- {
- case 1: m_Flags |= MB_DEFBUTTON1; break;
- case 2: m_Flags |= MB_DEFBUTTON2; break;
- case 3: m_Flags |= MB_DEFBUTTON3; break;
- case 4: m_Flags |= MB_DEFBUTTON4; break;
- }
- switch (m_StandardIcon)
- {
- case 1: m_Flags |= MB_ICONEXCLAMATION; break;
- case 2: m_Flags |= MB_ICONQUESTION; break;
- case 3: m_Flags |= MB_ICONSTOP; break;
- case 4: m_Flags |= MB_ICONWARNING; break;
- }
-
- // set m_IconNumber
- m_IconNumber = 0;
- switch (m_ResourceIcon)
- {
- case 1: m_IconNumber = IDR_MAINFRAME; break;
- }
- }
- }
-
- BOOL CMessageBoxOptions::OnInitDialog()
- {
- CPropertyPage::OnInitDialog();
-
- CSpinButtonCtrl *pSpin;
-
- if ((pSpin = (CSpinButtonCtrl *)GetDlgItem(IDC_SECONDS_SPIN)) != 0)
- {
- ASSERT_VALID(pSpin);
- pSpin->SetRange(0, 600);
- }
- else
- ASSERT(FALSE);
-
- InitCombos();
- OnChangeStandardButtons();
- return TRUE;
- }
-
- void CMessageBoxOptions::InitCombos ()
- {
- CComboBox *pTitle, *pMessage, *pFuture;
-
- if ((pTitle = (CComboBox *)GetDlgItem(IDC_TITLE_BOX)) != 0)
- ReloadComboList(pTitle, m_pTitleMRU, m_TitleText);
- else
- ASSERT(FALSE);
-
- if ((pMessage = (CComboBox *)GetDlgItem(IDC_MESSAGE_BOX)) != 0)
- ReloadComboList(pMessage, m_pMessageMRU, m_MessageText);
- else
- ASSERT(FALSE);
-
- if ((pFuture = (CComboBox *)GetDlgItem(IDC_DISPLAY_IN_FUTURE)) != 0)
- ReloadComboList(pFuture, m_pFutureMRU, m_DisplayInFutureText);
- else
- ASSERT(FALSE);
- }
-
- void CMessageBoxOptions::OnChangeStandardButtons()
- {
- CComboBox *pCombo;
- CButton *pCustomButtons;
- int index;
-
- if ((pCombo = (CComboBox *)GetDlgItem(IDC_STANDARD_BUTTONS)) != 0 &&
- (pCustomButtons = (CButton *)GetDlgItem(IDC_CUSTOM_BUTTONS)) != 0)
- {
- if ((index = pCombo->GetCurSel()) == 0)
- pCustomButtons->EnableWindow(TRUE);
- else
- pCustomButtons->EnableWindow(FALSE);
- }
- else
- ASSERT(FALSE);
- }
-
- void CMessageBoxOptions::OnCustomButtons()
- {
- CButtonList dialog(m_ButtonList, this);
- dialog.DoModal();
- }
-
- void CMessageBoxOptions::OnActivate (UINT nState, CWnd* pWndOther, BOOL bMinimized)
- {
- CPropertyPage::OnActivate(nState, pWndOther, bMinimized);
- if (DisableControls)
- CtlHTMLDialogEnable(m_hWnd, nState != WA_INACTIVE);
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CDetailsBoxOptions property page
-
- IMPLEMENT_DYNCREATE(CDetailsBoxOptions, CPropertyPage)
-
- BEGIN_MESSAGE_MAP(CDetailsBoxOptions, CPropertyPage)
- //{{AFX_MSG_MAP(CDetailsBoxOptions)
- ON_CBN_SELCHANGE(IDC_STANDARD_BUTTONS, OnChangeStandardButtons)
- ON_BN_CLICKED(IDC_CUSTOM_BUTTONS, OnCustomButtons)
- ON_WM_ACTIVATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- CDetailsBoxOptions::CDetailsBoxOptions() : CPropertyPage(CDetailsBoxOptions::IDD)
- {
- //{{AFX_DATA_INIT(CDetailsBoxOptions)
- m_DefaultButton = -1;
- m_DetailsText = _T("");
- m_DisplayInFutureText = _T("");
- m_HelpID = 0;
- m_MessageText = _T("");
- m_ResourceIcon = -1;
- m_ReturnValue = _T("");
- m_StandardButtons = -1;
- m_StandardIcon = -1;
- m_Timeout = -1;
- m_TitleText = _T("");
- //}}AFX_DATA_INIT
-
- m_ButtonList[0].ID = -1;
- m_pButtonList = 0;
- m_Flags = 0;
- m_IconNumber = 0;
- m_pTitleMRU = m_pMessageMRU = m_pDetailsMRU = m_pFutureMRU = 0;
- }
-
- CDetailsBoxOptions::~CDetailsBoxOptions()
- {
- }
-
- void CDetailsBoxOptions::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
-
- //{{AFX_DATA_MAP(CDetailsBoxOptions)
- DDX_CBIndex(pDX, IDC_DEFAULT_BUTTONS, m_DefaultButton);
- DDX_CBString(pDX, IDC_DETAILS_BOX, m_DetailsText);
- DDX_CBString(pDX, IDC_DISPLAY_IN_FUTURE, m_DisplayInFutureText);
- DDX_Text(pDX, IDC_HELPID, m_HelpID);
- DDX_CBString(pDX, IDC_MESSAGE_BOX, m_MessageText);
- DDX_CBIndex(pDX, IDC_RESOURCE_ICON, m_ResourceIcon);
- DDX_Text(pDX, IDC_RETURN_VALUE, m_ReturnValue);
- DDX_CBIndex(pDX, IDC_STANDARD_BUTTONS, m_StandardButtons);
- DDX_CBIndex(pDX, IDC_STANDARD_ICON, m_StandardIcon);
- DDX_Text(pDX, IDC_TIMEOUT_TIME, m_Timeout);
- DDV_MinMaxInt(pDX, m_Timeout, 0, 600);
- DDX_CBString(pDX, IDC_TITLE_BOX, m_TitleText);
- //}}AFX_DATA_MAP
-
- if (pDX->m_bSaveAndValidate)
- {
- // add current strings to MRU
- m_pTitleMRU->AddString(m_TitleText);
- m_pMessageMRU->AddString(m_MessageText);
- m_pDetailsMRU->AddString(m_DetailsText);
- m_pFutureMRU->AddString(m_DisplayInFutureText);
-
- // set m_pButtonList
- if (m_StandardButtons == 0)
- m_pButtonList = m_ButtonList;
- else
- m_pButtonList = 0;
-
- // set m_Flags
- m_Flags = 0;
- switch (m_StandardButtons)
- {
- case 1: m_Flags |= HTMLMB_CANCEL; break;
- case 2: m_Flags |= HTMLMB_CONTINUE; break;
- case 3: m_Flags |= MB_OK; break;
- case 4: m_Flags |= MB_OKCANCEL; break;
- case 5: m_Flags |= MB_RETRYCANCEL; break;
- case 6: m_Flags |= MB_YESNO; break;
- case 7: m_Flags |= MB_YESNOCANCEL; break;
- }
- switch (m_DefaultButton)
- {
- case 1: m_Flags |= MB_DEFBUTTON1; break;
- case 2: m_Flags |= MB_DEFBUTTON2; break;
- case 3: m_Flags |= MB_DEFBUTTON3; break;
- case 4: m_Flags |= MB_DEFBUTTON4; break;
- }
- switch (m_StandardIcon)
- {
- case 1: m_Flags |= MB_ICONEXCLAMATION; break;
- case 2: m_Flags |= MB_ICONQUESTION; break;
- case 3: m_Flags |= MB_ICONSTOP; break;
- case 4: m_Flags |= MB_ICONWARNING; break;
- }
-
- // set m_IconNumber
- m_IconNumber = 0;
- switch (m_ResourceIcon)
- {
- case 1: m_IconNumber = IDR_MAINFRAME; break;
- }
- }
- }
-
- BOOL CDetailsBoxOptions::OnInitDialog()
- {
- CPropertyPage::OnInitDialog();
-
- CSpinButtonCtrl *pSpin;
-
- if ((pSpin = (CSpinButtonCtrl *)GetDlgItem(IDC_SECONDS_SPIN)) != 0)
- {
- ASSERT_VALID(pSpin);
- pSpin->SetRange(0, 600);
- }
- else
- ASSERT(FALSE);
-
- InitCombos();
- OnChangeStandardButtons();
- return TRUE;
- }
-
- void CDetailsBoxOptions::InitCombos ()
- {
- CComboBox *pTitle, *pMessage, *pDetails, *pFuture;
-
- if ((pTitle = (CComboBox *)GetDlgItem(IDC_TITLE_BOX)) != 0)
- ReloadComboList(pTitle, m_pTitleMRU, m_TitleText);
- else
- ASSERT(FALSE);
-
- if ((pMessage = (CComboBox *)GetDlgItem(IDC_MESSAGE_BOX)) != 0)
- ReloadComboList(pMessage, m_pMessageMRU, m_MessageText);
- else
- ASSERT(FALSE);
-
- if ((pDetails = (CComboBox *)GetDlgItem(IDC_DETAILS_BOX)) != 0)
- ReloadComboList(pDetails, m_pDetailsMRU, m_DetailsText);
- else
- ASSERT(FALSE);
-
- if ((pFuture = (CComboBox *)GetDlgItem(IDC_DISPLAY_IN_FUTURE)) != 0)
- ReloadComboList(pFuture, m_pFutureMRU, m_DisplayInFutureText);
- else
- ASSERT(FALSE);
- }
-
- void CDetailsBoxOptions::OnChangeStandardButtons()
- {
- CComboBox *pCombo;
- CButton *pCustomButtons;
- int index;
-
- if ((pCombo = (CComboBox *)GetDlgItem(IDC_STANDARD_BUTTONS)) != 0 &&
- (pCustomButtons = (CButton *)GetDlgItem(IDC_CUSTOM_BUTTONS)) != 0)
- {
- if ((index = pCombo->GetCurSel()) == 0)
- pCustomButtons->EnableWindow(TRUE);
- else
- pCustomButtons->EnableWindow(FALSE);
- }
- else
- ASSERT(FALSE);
- }
-
- void CDetailsBoxOptions::OnCustomButtons()
- {
- CButtonList dialog(m_ButtonList, this);
- dialog.DoModal();
- }
-
- void CDetailsBoxOptions::OnActivate (UINT nState, CWnd* pWndOther, BOOL bMinimized)
- {
- CPropertyPage::OnActivate(nState, pWndOther, bMinimized);
- if (DisableControls)
- CtlHTMLDialogEnable(m_hWnd, nState != WA_INACTIVE);
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CFlashBoxOptions property page
-
- IMPLEMENT_DYNCREATE(CFlashBoxOptions, CPropertyPage)
-
- BEGIN_MESSAGE_MAP(CFlashBoxOptions, CPropertyPage)
- //{{AFX_MSG_MAP(CFlashBoxOptions)
- ON_WM_ACTIVATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- CFlashBoxOptions::CFlashBoxOptions() : CPropertyPage(CFlashBoxOptions::IDD)
- {
- //{{AFX_DATA_INIT(CFlashBoxOptions)
- m_DisplayInFutureText = _T("");
- m_MessageText = _T("");
- m_ResourceIcon = -1;
- m_StandardIcon = -1;
- m_Timeout = -1;
- m_TitleText = _T("");
- //}}AFX_DATA_INIT
-
- m_Flags = 0;
- m_IconNumber = 0;
- m_pTitleMRU = m_pMessageMRU = m_pFutureMRU = 0;
- }
-
- CFlashBoxOptions::~CFlashBoxOptions()
- {
- }
-
- void CFlashBoxOptions::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CFlashBoxOptions)
- DDX_CBString(pDX, IDC_DISPLAY_IN_FUTURE, m_DisplayInFutureText);
- DDX_CBString(pDX, IDC_MESSAGE_BOX, m_MessageText);
- DDX_CBIndex(pDX, IDC_RESOURCE_ICON, m_ResourceIcon);
- DDX_CBIndex(pDX, IDC_STANDARD_ICON, m_StandardIcon);
- DDX_Text(pDX, IDC_TIMEOUT_TIME, m_Timeout);
- DDV_MinMaxInt(pDX, m_Timeout, 1, 600);
- DDX_CBString(pDX, IDC_TITLE_BOX, m_TitleText);
- //}}AFX_DATA_MAP
-
- if (pDX->m_bSaveAndValidate)
- {
- // add current strings to MRU
- m_pTitleMRU->AddString(m_TitleText);
- m_pMessageMRU->AddString(m_MessageText);
- m_pFutureMRU->AddString(m_DisplayInFutureText);
-
- // set m_Flags
- m_Flags = 0;
- switch (m_StandardIcon)
- {
- case 1: m_Flags |= MB_ICONEXCLAMATION; break;
- case 2: m_Flags |= MB_ICONQUESTION; break;
- case 3: m_Flags |= MB_ICONSTOP; break;
- case 4: m_Flags |= MB_ICONWARNING; break;
- }
-
- // set m_IconNumber
- m_IconNumber = 0;
- switch (m_ResourceIcon)
- {
- case 1: m_IconNumber = IDR_MAINFRAME; break;
- }
- }
- }
-
- BOOL CFlashBoxOptions::OnInitDialog()
- {
- CPropertyPage::OnInitDialog();
-
- CSpinButtonCtrl *pSpin;
-
- if ((pSpin = (CSpinButtonCtrl *)GetDlgItem(IDC_SECONDS_SPIN)) != 0)
- {
- ASSERT_VALID(pSpin);
- pSpin->SetRange(1, 600);
- }
- else
- ASSERT(FALSE);
-
- InitCombos();
- return TRUE;
- }
-
- void CFlashBoxOptions::InitCombos ()
- {
- CComboBox *pTitle, *pMessage, *pFuture;
-
- if ((pTitle = (CComboBox *)GetDlgItem(IDC_TITLE_BOX)) != 0)
- ReloadComboList(pTitle, m_pTitleMRU, m_TitleText);
- else
- ASSERT(FALSE);
-
- if ((pMessage = (CComboBox *)GetDlgItem(IDC_MESSAGE_BOX)) != 0)
- ReloadComboList(pMessage, m_pMessageMRU, m_MessageText);
- else
- ASSERT(FALSE);
-
- if ((pFuture = (CComboBox *)GetDlgItem(IDC_DISPLAY_IN_FUTURE)) != 0)
- ReloadComboList(pFuture, m_pFutureMRU, m_DisplayInFutureText);
- else
- ASSERT(FALSE);
- }
-
- void CFlashBoxOptions::OnActivate (UINT nState, CWnd* pWndOther, BOOL bMinimized)
- {
- CPropertyPage::OnActivate(nState, pWndOther, bMinimized);
- if (DisableControls)
- CtlHTMLDialogEnable(m_hWnd, nState != WA_INACTIVE);
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CMessageOptions
-
- static int ActivePage = 0;
-
- IMPLEMENT_DYNAMIC(CMessageOptions, CMcPropertySheet)
-
- BEGIN_MESSAGE_MAP(CMessageOptions, CMcPropertySheet)
- //{{AFX_MSG_MAP(CMessageOptions)
- ON_WM_DESTROY()
- ON_COMMAND(ID_TEST, OnTest)
- ON_WM_ACTIVATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- CMessageOptions::CMessageOptions(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
- :CMcPropertySheet(nIDCaption, pParentWnd, iSelectPage)
- {
- AddPage(&m_MessageBoxOptions);
- AddPage(&m_DetailsBoxOptions);
- AddPage(&m_FlashBoxOptions);
- }
-
- CMessageOptions::CMessageOptions(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
- :CMcPropertySheet(pszCaption, pParentWnd, iSelectPage)
- {
- AddPage(&m_MessageBoxOptions);
- AddPage(&m_DetailsBoxOptions);
- AddPage(&m_FlashBoxOptions);
- }
-
- CMessageOptions::~CMessageOptions()
- {
- }
-
- BOOL CMessageOptions::OnInitDialog()
- {
- McButtonList buttonList[4];
- CRect rect;
-
- // create a button list
- buttonList[0].Name = "OK";
- buttonList[0].ID = IDOK;
- buttonList[0].IsDefault = FALSE;
-
- buttonList[1].Name = "Cancel";
- buttonList[1].ID = IDCANCEL;
- buttonList[1].IsDefault = FALSE;
-
- buttonList[2].Name = "&Test";
- buttonList[2].ID = ID_TEST;
- buttonList[2].IsDefault = TRUE;
-
- buttonList[3].ID = -1;
-
- SetButtons(buttonList);
-
- BOOL bResult = CMcPropertySheet::OnInitDialog();
-
- // restore the active page
- SetActivePage(ActivePage);
-
- // handle window placement
- CMcWindowPlacement wp;
- wp.RestoreWindowPlacement(_T("Message Boxes"), _T("WindowPlacement"), this, TRUE);
-
- return bResult;
- }
-
- void CMessageOptions::OnDestroy()
- {
- // save active page
- ActivePage = GetActiveIndex();
-
- // handle window placement
- CMcWindowPlacement wp;
- wp.SaveWindowPlacement(_T("Message Boxes"), _T("WindowPlacement"), this);
-
- CMcPropertySheet::OnDestroy();
- }
-
- void CMessageOptions::OnTest()
- {
- CWnd *pReturnValue;
- CString returnValue;
- int retVal = 0, value;
-
- if (GetActiveIndex() == 0)
- {
- if (m_MessageBoxOptions.UpdateData() == 0)
- return;
-
- retVal = HTMLMessageBox(m_MessageBoxOptions.m_MessageText, m_MessageBoxOptions.m_TitleText, m_MessageBoxOptions.m_Flags,
- m_MessageBoxOptions.m_DisplayInFutureText, m_MessageBoxOptions.m_pButtonList,
- m_MessageBoxOptions.m_Timeout, m_MessageBoxOptions.m_IconNumber, m_MessageBoxOptions.m_HelpID);
-
- // set return value
- if ((pReturnValue = m_MessageBoxOptions.GetDlgItem(IDC_RETURN_VALUE)) != 0)
- {
- value = retVal & ~HTMLID_DONTASKAGAIN;
- returnValue.Format(_T("%d"), value);
- if (retVal & HTMLID_DONTASKAGAIN)
- returnValue += _T(" Don't ask in the future.");
- pReturnValue->SetWindowText(returnValue);
- }
- else
- ASSERT(FALSE);
-
- m_MessageBoxOptions.InitCombos();
- }
- else if (GetActiveIndex() == 1)
- {
- BOOL showUnfolded = FALSE;
-
- if (m_DetailsBoxOptions.UpdateData() == 0)
- return;
-
- retVal = HTMLDetailsBox(m_DetailsBoxOptions.m_MessageText, m_DetailsBoxOptions.m_TitleText,
- m_DetailsBoxOptions.m_DetailsText, CSize(200, 40), showUnfolded, m_DetailsBoxOptions.m_Flags,
- m_DetailsBoxOptions.m_DisplayInFutureText, m_DetailsBoxOptions.m_pButtonList,
- m_DetailsBoxOptions.m_Timeout, m_DetailsBoxOptions.m_IconNumber, m_DetailsBoxOptions.m_HelpID);
-
- // set return value
- if ((pReturnValue = m_DetailsBoxOptions.GetDlgItem(IDC_RETURN_VALUE)) != 0)
- {
- value = retVal & ~HTMLID_DONTASKAGAIN;
- returnValue.Format(_T("%d"), value);
- if (retVal & HTMLID_DONTASKAGAIN)
- returnValue += _T(" Don't ask in the future.");
- pReturnValue->SetWindowText(returnValue);
- }
- else
- ASSERT(FALSE);
-
- m_DetailsBoxOptions.InitCombos();
- }
- else
- {
- if (m_FlashBoxOptions.UpdateData() == 0)
- return;
-
- retVal = HTMLFlashBox(m_FlashBoxOptions.m_MessageText, m_FlashBoxOptions.m_TitleText,
- m_FlashBoxOptions.m_Timeout, m_FlashBoxOptions.m_Flags, m_FlashBoxOptions.m_DisplayInFutureText,
- m_FlashBoxOptions.m_IconNumber);
-
- m_FlashBoxOptions.InitCombos();
- }
- }
-
- void CMessageOptions::OnActivate (UINT nState, CWnd* pWndOther, BOOL bMinimized)
- {
- CMcPropertySheet::OnActivate(nState, pWndOther, bMinimized);
- if (DisableControls)
- CtlHTMLDialogEnable(m_hWnd, nState != WA_INACTIVE);
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CButtonList dialog
-
- BEGIN_MESSAGE_MAP(CButtonList, CDialog)
- //{{AFX_MSG_MAP(CButtonList)
- ON_BN_CLICKED(IDC_NEW_ITEM, OnNewItem)
- ON_BN_CLICKED(IDC_EDIT_ITEM, OnEditItem)
- ON_BN_CLICKED(IDC_REMOVE_ALL, OnRemoveAll)
- ON_BN_CLICKED(IDC_REMOVE_ITEM, OnRemoveItem)
- ON_WM_ACTIVATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- CButtonList::CButtonList(HTMLButtonList *pButtonList, CWnd* pParent /*=NULL*/)
- : CDialog(CButtonList::IDD, pParent), m_pButtonList(pButtonList)
- {
- //{{AFX_DATA_INIT(CButtonList)
- //}}AFX_DATA_INIT
- }
-
- void CButtonList::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CButtonList)
- //}}AFX_DATA_MAP
-
- if (pDX->m_bSaveAndValidate)
- {
- CListCtrl *pList;
- CString temp;
- int item, items;
-
- // ENHANCE: could improve by saving and restoring to registry
- if ((pList = (CListCtrl *)GetDlgItem(IDC_BUTTON_LIST)) == 0)
- {
- ASSERT(FALSE);
- return;
- }
-
- // fill in the button list based on the selections
- items = pList->GetItemCount();
- for (item = 0; item < items; item++)
- {
- _tcscpy(m_pButtonList[item].Name, pList->GetItemText(item, 0));
- temp = pList->GetItemText(item, 1);
- m_pButtonList[item].ID = atoi(temp);
- temp = pList->GetItemText(item, 2);
- if (temp.IsEmpty())
- m_pButtonList[item].IsDefault = FALSE;
- else
- m_pButtonList[item].IsDefault = TRUE;
- }
- m_pButtonList[item].ID = -1;
- }
- }
-
- BOOL CButtonList::OnInitDialog()
- {
- CListCtrl *pList;
- CString temp;
- CRect rect;
-
- CDialog::OnInitDialog();
-
- // init list
- if ((pList = (CListCtrl *)GetDlgItem(IDC_BUTTON_LIST)) != 0)
- {
- // init columns
- pList->GetClientRect(&rect);
- pList->InsertColumn(0, _T("Name"), LVCFMT_LEFT, rect.right / 2);
- pList->InsertColumn(1, _T("ID"), LVCFMT_RIGHT, rect.right / 4);
- pList->InsertColumn(2, _T("Default"), LVCFMT_CENTER, rect.right / 4);
-
- // loop through button list
- for (int i = 0; ; i++)
- {
- if (m_pButtonList[i].ID == -1)
- break;
- pList->InsertItem(i, m_pButtonList[i].Name);
- temp.Format(_T("%d"), m_pButtonList[i].ID);
- pList->SetItemText(i, 1, temp);
- if (m_pButtonList[i].IsDefault)
- temp = _T("x");
- else
- temp.Empty();
- pList->SetItemText(i, 2, temp);
- }
- }
- else
- ASSERT(FALSE);
-
- EnableButtons();
-
- return TRUE;
- }
-
- void CButtonList::OnNewItem()
- {
- CListCtrl *pList;
- CString temp;
- int item, items;
-
- if ((pList = (CListCtrl *)GetDlgItem(IDC_BUTTON_LIST)) == 0)
- {
- ASSERT(FALSE);
- return;
- }
-
- // enforce the maximum button count
- if ((items = pList->GetItemCount()) >= MaxButtonsCount)
- {
- HTMLMessageBox(_T("The button list already has the maximum number of buttons.\nRemove another button and try again."), 0, MB_ICONSTOP);
- return;
- }
-
- if (items == 0)
- {
- // the list is empty, so we don't need to know the insertion location - use the CEditButton
- CEditButton dialog(this, _T("Add Button"));
-
- if (dialog.DoModal() == IDOK)
- {
- pList->InsertItem(0, dialog.m_Name);
- temp.Format(_T("%d"), dialog.m_ID);
- pList->SetItemText(0, 1, temp);
- if (dialog.m_IsDefault)
- temp = _T("x");
- else
- temp.Empty();
- pList->SetItemText(0, 2, temp);
- }
- }
- else
- {
- LV_ITEM itemInfo;
-
- // find the selected button
- for (item = 0; item < MaxButtonsCount; item++)
- {
- ZeroMemory(&itemInfo, sizeof(itemInfo));
- itemInfo.mask = LVIF_STATE;
- itemInfo.stateMask = LVIS_SELECTED;
- itemInfo.iItem = item;
- if (pList->GetItem(&itemInfo) == 0)
- {
- // default to the last item
- item = max(0, pList->GetItemCount() - 1);
- break;
- }
- if (itemInfo.state & LVIS_SELECTED)
- break;
- }
-
- CAddButton dialog(this);
-
- if (dialog.DoModal() == IDOK)
- {
- if (dialog.m_InsertAfter)
- item++;
- pList->InsertItem(item, dialog.m_Name);
- temp.Format(_T("%d"), dialog.m_ID);
- pList->SetItemText(item, 1, temp);
- if (dialog.m_IsDefault)
- temp = _T("x");
- else
- temp.Empty();
- pList->SetItemText(item, 2, temp);
- }
- }
-
- EnableButtons();
- }
-
- void CButtonList::OnEditItem()
- {
- LV_ITEM itemInfo;
- CListCtrl *pList;
- CString temp;
- int item;
-
- if ((pList = (CListCtrl *)GetDlgItem(IDC_BUTTON_LIST)) == 0)
- {
- ASSERT(FALSE);
- return;
- }
-
- // find the selected button
- for (item = 0; item < MaxButtonsCount; item++)
- {
- ZeroMemory(&itemInfo, sizeof(itemInfo));
- itemInfo.mask = LVIF_STATE;
- itemInfo.stateMask = LVIS_SELECTED;
- itemInfo.iItem = item;
- if (pList->GetItem(&itemInfo) == 0)
- {
- HTMLMessageBox(_T("You must select the button that you want to change."),
- 0, MB_ICONWARNING);
- return;
- }
- if (itemInfo.state & LVIS_SELECTED)
- break;
- }
-
- CEditButton dialog(this);
-
- // init values
- dialog.m_Name = pList->GetItemText(item, 0);
- temp = pList->GetItemText(item, 1);
- dialog.m_ID = atoi(temp);
- temp = pList->GetItemText(item, 2);
- if (temp.IsEmpty())
- dialog.m_IsDefault = FALSE;
- else
- dialog.m_IsDefault = TRUE;
-
- if (dialog.DoModal() == IDOK)
- {
- pList->SetItemText(item, 0, dialog.m_Name);
- temp.Format(_T("%d"), dialog.m_ID);
- pList->SetItemText(item, 1, temp);
- if (dialog.m_IsDefault)
- temp = _T("x");
- else
- temp.Empty();
- pList->SetItemText(item, 2, temp);
- }
- }
-
- void CButtonList::OnRemoveAll()
- {
- CListCtrl *pList;
-
- if ((pList = (CListCtrl *)GetDlgItem(IDC_BUTTON_LIST)) != 0)
- pList->DeleteAllItems();
- else
- ASSERT(FALSE);
-
- EnableButtons();
- }
-
- void CButtonList::OnRemoveItem()
- {
- CListCtrl *pList;
- LV_ITEM itemInfo;
- int item;
-
- if ((pList = (CListCtrl *)GetDlgItem(IDC_BUTTON_LIST)) == 0)
- {
- ASSERT(FALSE);
- return;
- }
-
- // find the selected button
- for (item = 0; item < MaxButtonsCount; item++)
- {
- ZeroMemory(&itemInfo, sizeof(itemInfo));
- itemInfo.mask = LVIF_STATE;
- itemInfo.stateMask = LVIS_SELECTED;
- itemInfo.iItem = item;
- if (pList->GetItem(&itemInfo) == 0)
- return;
- if (itemInfo.state & LVIS_SELECTED)
- break;
- }
-
- // delete the selected item
- pList->DeleteItem(item);
-
- EnableButtons();
- }
-
- void CButtonList::EnableButtons()
- {
- CListCtrl *pList;
- CButton *pEditItem, *pRemoveItem, *pRemoveAll, *pOK;
- int items;
- BOOL enableButtons = TRUE;
-
- if ((pList = (CListCtrl *)GetDlgItem(IDC_BUTTON_LIST)) == 0)
- {
- ASSERT(FALSE);
- return;
- }
- if ((pOK = (CButton *)GetDlgItem(IDOK)) == 0)
- {
- ASSERT(FALSE);
- return;
- }
- if ((pEditItem = (CButton *)GetDlgItem(IDC_EDIT_ITEM)) == 0)
- {
- ASSERT(FALSE);
- return;
- }
- if ((pRemoveItem = (CButton *)GetDlgItem(IDC_REMOVE_ITEM)) == 0)
- {
- ASSERT(FALSE);
- return;
- }
- if ((pRemoveAll = (CButton *)GetDlgItem(IDC_REMOVE_ALL)) == 0)
- {
- ASSERT(FALSE);
- return;
- }
-
- if ((items = pList->GetItemCount()) == 0)
- {
- enableButtons = FALSE;
-
- // set focus on OK, otherwise focus may get "trapped" on a diabled button
- pOK->SetFocus();
- }
-
- pEditItem->EnableWindow(enableButtons);
- pRemoveItem->EnableWindow(enableButtons);
- pRemoveAll->EnableWindow(enableButtons);
- }
-
- void CButtonList::OnActivate (UINT nState, CWnd* pWndOther, BOOL bMinimized)
- {
- CDialog::OnActivate(nState, pWndOther, bMinimized);
- if (DisableControls)
- CtlHTMLDialogEnable(m_hWnd, nState != WA_INACTIVE);
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CAddButton dialog
-
- BEGIN_MESSAGE_MAP(CAddButton, CDialog)
- //{{AFX_MSG_MAP(CAddButton)
- ON_WM_ACTIVATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- CAddButton::CAddButton(CWnd* pParent /*=NULL*/)
- : CDialog(CAddButton::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CAddButton)
- m_ID = DefaultButtonID++;
- m_InsertAfter = 1;
- m_IsDefault = FALSE;
- m_Name = _T("");
- //}}AFX_DATA_INIT
- }
-
- void CAddButton::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAddButton)
- DDX_Text(pDX, IDC_ID, m_ID);
- DDV_MinMaxUInt(pDX, m_ID, 1, 65535);
- DDX_Radio(pDX, IDC_INSERT_BEFORE, m_InsertAfter);
- DDX_Check(pDX, IDC_IS_DEFAULT, m_IsDefault);
- DDX_Text(pDX, IDC_NAME, m_Name);
- //}}AFX_DATA_MAP
- }
-
- void CAddButton::OnActivate (UINT nState, CWnd* pWndOther, BOOL bMinimized)
- {
- CDialog::OnActivate(nState, pWndOther, bMinimized);
- if (DisableControls)
- CtlHTMLDialogEnable(m_hWnd, nState != WA_INACTIVE);
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CEditButton dialog
-
- BEGIN_MESSAGE_MAP(CEditButton, CDialog)
- //{{AFX_MSG_MAP(CEditButton)
- ON_WM_ACTIVATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- CEditButton::CEditButton(CWnd* pParent, LPCTSTR title)
- : CDialog(CEditButton::IDD, pParent), m_Title(title)
- {
- //{{AFX_DATA_INIT(CEditButton)
- m_ID = 0;
- m_IsDefault = FALSE;
- m_Name = _T("");
- //}}AFX_DATA_INIT
- }
-
- void CEditButton::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CEditButton)
- DDX_Text(pDX, IDC_ID, m_ID);
- DDV_MinMaxUInt(pDX, m_ID, 1, 65535);
- DDX_Check(pDX, IDC_IS_DEFAULT, m_IsDefault);
- DDX_Text(pDX, IDC_NAME, m_Name);
- //}}AFX_DATA_MAP
- }
-
- BOOL CEditButton::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- if (m_Title)
- SetWindowText(m_Title);
-
- return TRUE;
- }
-
- void CEditButton::OnActivate (UINT nState, CWnd* pWndOther, BOOL bMinimized)
- {
- CDialog::OnActivate(nState, pWndOther, bMinimized);
- if (DisableControls)
- CtlHTMLDialogEnable(m_hWnd, nState != WA_INACTIVE);
- }
-